import 'babel-polyfill';
import 'flex.css/dist/data-flex.css';
import dva from 'dva';
import "lodash"
import './index.less';
import VConsole from "vconsole";
// let vConsole = new VConsole(); //生产环境也会显示1

// ;(function () {
// 	if (!/mdebug=true/.test(window.location.href)) return;
// 	var script = document.createElement('script')
// 	script.src = "https://cdn.bootcss.com/eruda/1.2.6/eruda.min.js"
// 	script.async = true
// 	document.getElementsByTagName('head')[0].appendChild(script)
// 	script.onload = function () {
// 			eruda.init()
// 	}
// })()
// 地址栏加 &mdebug=true



localStorage.removeItem(MI_APP_CODE+"historyTop");
// import {createBrowserHistory} from "history";
// 1. Initialize
const app = dva({
	onError(err, dispatch) {
		if (err.resp) {
			console.error(err.resp.msg);
		}
		else if (err.srv) {
			console.error(err.srv.msg);
		}
		else {
			console.error(err);
		}
	},
	// history:createBrowserHistory()//使用browserHistory  路径 /page?_c=xxx; hashHistory 路径/#/page?_c=xxx
});

// 2. Plugins
// app.use();

// 3. Model
// Moved to router.js
// let models = ["global","form","page","login"];
// models.map(i=>{
// 	app.model(require('./models/'+i))
// })
app.model(require('./models/global'));
app.model(require('./models/form'));
app.model(require('./models/page'));
app.model(require('./models/login'));

// 4. Router
app.router(require('./router.jsx'));

// 5. Start
app.start('#root');

